package com.api.regression.group.getdocument;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.test.util.TestPattern;
import com.zyncro.api.IGroupApiService;
import com.zyncro.api.exceptions.ZyncroApiException;

@ContextConfiguration(locations = { "classpath:/group/group-context.xml" })
public class GetDocumentExternalGroup extends AbstractApiTest {

	@Value("#{groupdocuments['user.getDocuments'].appId}")
	private String userUrn;

	@Value("#{groupdocuments['user.getDocuments'].password}")
	private String userPassword;

	@Value("#{groupdocuments['group.externalOpen'].urn}")
	private String groupUrn;

	@Value("#{groupdocuments['group.externalOpen'].documentFileUrn}")
	private String documentFileUrn;

	@BeforeClass
	protected void loginUser() throws Exception {

		getApi().login(userUrn, userPassword);
	}

	@Test(expectedExceptions = { ZyncroApiException.class }, expectedExceptionsMessageRegExp = TestPattern.ANYTHING_BUT_NULL)
	public void testGetPrivateGroupDocuments() throws ZyncroApiException {

		getApi().getService(IGroupApiService.class).getDocument(groupUrn, documentFileUrn);
	}
}
